package com.bawei.rk_01

import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bawei.base.utils.mvvm.BaseViewActivity
import com.bawei.rk_01.databinding.ActivityMainBinding

@Route(path = "/app/MainActivity")

class MainActivity : BaseViewActivity<ActivityMainBinding>() {

    @Autowired(name = "ym")
    @JvmField
    var index : Int = 0

    override fun getLayout(): Int {
        return R.layout.activity_main
    }

    override fun initView() {

//        //找到导航宿主
//        val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
//        //找到宿主导航器
//        val navController = navHostFragment.navController
//        //和bottom联动
//        binding.bottom.setupWithNavController(navController)

        // 将底部导航视图与导航控制器关联
        binding.bottom.setupWithNavController(findNavController(R.id.fragmentContainerView))

        ARouter.getInstance().inject(this)
        binding.bottom.selectedItemId  = when(index){
            0->R.id.homeFragment
            1->R.id.categoryFragment
            2->R.id.carFragment
            3->R.id.mineFragment
            else -> {R.id.homeFragment}
        }

    }

    override fun initData() {

    }

}
